import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.regex.Pattern;


public class TIJIO {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		File path = new File("D://tempfold");
		String[] list;
		list = path.list();
		for (int i = 0; i < list.length; ++i)
			System.out.println(list[i]);
		File[] filelist = path.listFiles();
		for (int i = 0; i < filelist.length; ++i) {
			System.out.println(filelist[i].getCanonicalPath());
		}
		final String regex = "\\w*\\.txt";
		list = path.list(new FilenameFilter() {
			private Pattern pattern = Pattern.compile(regex);
			@Override
			public boolean accept(File dir, String name) {
	            
				return pattern.matcher(new File(name).getName()).matches();
			}
			
		});
		for (int i = 0; i < list.length; ++i)
			System.out.println(list[i]);
	}

}
